<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWaybillsTable extends Migration
{
    /**
     * 运单表
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('waybills', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->unsignedInteger('owner_id')->index('owner_id')->comment('货主id');
            $table->unsignedInteger('driver_id')->index('driver_id')->comment('车主id');
            $table->unsignedInteger('cargo_id')->index('cargo_id')->comment('货物id');
            $table->decimal('price')->comment('费用');
            $table->string('start_addr', 32)->comment('出发地');
            $table->string('end_addr', 32)->comment('到达地');
            $table->unsignedInteger('car_lenght')->comment('车长');
            $table->string('car_type', 32)->comment('车型');
            $table->string('type', 32)->comment('货物类型');
            $table->unsignedInteger('weight')->comment('货物重量');
            $table->tinyInteger('status')->default(0)->comment('状态：-1为已取消、0为待付款、1为运输中、2为已完成');
            $table->charset = 'utf8';
            $table->collation = 'utf8_unicode_ci';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('waybills');
    }
}
